##################################################################################################################################
#
# Copyright (C) 2008-2013 Mind System Connection. Lda. Part of Daidze Software, created by Siqsuruq. All other rights reserved.
#
# Mind System Connection Webpage: www.msysc.org
# Daidze Software Page: www.daidze.com www.daidze.org
# E-mail: admin@msysc.org, siqsuruq@gmail.com
#
# commify - Jeff Hobbs
# round - thommey and robeadam from http://tclhelp.net/unb/169
##################################################################################################################################

proc round {number} {
	if {$::round_num eq "yes"} {
		set digits $::round_digits
		if {$digits != 0} {
			return [expr {round(pow(10,$digits)*$number)/pow(10,$digits)}]
		} else {
			return [expr round($number)]

		}
	} else {
		return $number
	}
}

proc commify {num} {
    while {[regsub {^([-+]?\d+)(\d\d\d)} $num "\\1$::thousand_separator\\2" num]} {}
    return $num
}

proc add_procent {value procent} {
	set result [round [expr ((double($value) / 100) * double($procent)) + double($value)]]
	return $result
}

proc subtract_procent {value procent} {
	set result [round [expr double($value) - ((double($value) / 100) * double($procent))]]
	return $result
}